package com.cy.dao.impl;

import com.cy.dao.NoticeJdbc;
import com.cy.dao.pojo.NoticePojo;
import org.springframework.beans.factory.annotation.Autowired;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class NoticeJdbcImpl implements NoticeJdbc {

    @Autowired
    private DataSource dataSource;

    @Override
    public void insertNotice(Object[] values) throws SQLException {
        Connection conn = dataSource.getConnection();
        String sql = "insert into sys_notices" +
                "(title,content,type,status," +
                "createdTime,createdUser,modifiedTime,modifiedUser)" +
                " values(?,?,?,?,?,?,?,?)";
        PreparedStatement pre = conn.prepareStatement(sql);
        for (int i=0;i<values.length;i++){
            pre.setObject(i+1,values[i]);
        }
        pre.execute();

        pre.close();
        conn.close();
    }

    @Override
    public NoticePojo selectById(Object[] values) {
        return null;
    }
}
